require 'libs/turtle_status.lua'

function splitasd(s)
	i = 0
	l = 0
	strings = {}
	strings[0] = ""
	while l < string.len(s) do
		if s[l] == "\n" then
			i = i + 1
			strings[i] = ""
		else
			strings[i] = strings[i] .. string.sub(s, i+1, l)
		end
		l = l + 1
	end
	return strings
end

function displayTurtleStatus(side)
	if side == nil then
		print("Usage: display_turtle_status side")
		return
	end
	if peripheral.getType(side) ~= "monitor" then
		print("No monitor could be found on "..side.." side")
		return
	end

	mon = peripheral.wrap(side)
	term.redirect(mon)
	while true do
		mon.clear()
		mon.setCursorPos(1, 1)
		print(getTurtleStatus())
		os.sleep(2)
	end
	term.restore()
end

arg = { ... }

displayTurtleStatus(arg[1])